using Perfect.Marshal;
using System.Xml;

namespace editor
{
namespace cfg.equip
{
[System.Serializable]
public  class Talent :   cfg.EditorReadWriter 
 {

    public cfg.equip.EWeaponType weaponType ;
     public string weaponTypeIcon  = "";
     public string name  = "";
     public string featureIcon  = "";
     public string talentIcon  = "";
     public int normalSkill ;
     public System.Collections.Generic.List<cfg.equip.HoleSetting> holeSetting  = new System.Collections.Generic.List<cfg.equip.HoleSetting>();
     


    public const int TYPE_ID = 2062896684;

    public override int GetTypeId() {
        return TYPE_ID;
    }


    public override void MarshalCompatible(Perfect.Marshal.Octets os) {
        os.WriteSize(7);
        os.WriteSize(Tag.INT | (1 << Tag.TAG_SHIFT));  os.WriteInt((int)weaponType);  
         os.WriteSize(Tag.STRING | (2 << Tag.TAG_SHIFT));  os.WriteString(weaponTypeIcon);  
         os.WriteSize(Tag.STRING | (3 << Tag.TAG_SHIFT));  os.WriteString(name);  
         os.WriteSize(Tag.STRING | (4 << Tag.TAG_SHIFT));  os.WriteString(featureIcon);  
         os.WriteSize(Tag.STRING | (5 << Tag.TAG_SHIFT));  os.WriteString(talentIcon);  
         os.WriteSize(Tag.INT | (6 << Tag.TAG_SHIFT));  os.WriteInt(normalSkill);  
         os.WriteSize(Tag.LIST | (7 << Tag.TAG_SHIFT));  { var _oldOs = os; os = new Perfect.Marshal.Octets(); cfg.Extensions.marshal_compatible_list_cfg_equip_HoleSetting(holeSetting,os);  _oldOs.WriteOctets(os); os = _oldOs;}  
         
    }

    public override void UnmarshalCompatible(Perfect.Marshal.Octets os) {
        for (int _var_num_ = os.ReadSize(); _var_num_-- > 0; ) {
            int _id_ = os.ReadSize();
            switch (_id_)
            {
            case (Tag.INT | (1 << Tag.TAG_SHIFT)):   weaponType = (cfg.equip.EWeaponType)(os.ReadInt()); break;  
             case (Tag.STRING | (2 << Tag.TAG_SHIFT)):   weaponTypeIcon = os.ReadString(); break;  
             case (Tag.STRING | (3 << Tag.TAG_SHIFT)):   name = os.ReadString(); break;  
             case (Tag.STRING | (4 << Tag.TAG_SHIFT)):   featureIcon = os.ReadString(); break;  
             case (Tag.STRING | (5 << Tag.TAG_SHIFT)):   talentIcon = os.ReadString(); break;  
             case (Tag.INT | (6 << Tag.TAG_SHIFT)):   normalSkill = os.ReadInt(); break;  
             case (Tag.LIST | (7 << Tag.TAG_SHIFT)):  { var _oldOs = os; os = os.ReadOctets(); holeSetting = cfg.Extensions.unmarshal_compatible_list_cfg_equip_HoleSetting(os); os = _oldOs; break; }   
             
            default: Tag.SkipUnknownField(_id_, os); break;
            }
         }
    }
    public override void MarshalXml(XmlWriter ele)
    {
        ele.WriteAttributeString("type", "Talent");
        ele.WriteStartElement("weaponType"); ele.WriteAttributeString("id", "1"); ele.WriteEnum(weaponType); ele.WriteEndElement();
         ele.WriteStartElement("weaponTypeIcon"); ele.WriteAttributeString("id", "2"); ele.WriteString2(weaponTypeIcon); ele.WriteEndElement();
         ele.WriteStartElement("name"); ele.WriteAttributeString("id", "3"); ele.WriteString2(name); ele.WriteEndElement();
         ele.WriteStartElement("featureIcon"); ele.WriteAttributeString("id", "4"); ele.WriteString2(featureIcon); ele.WriteEndElement();
         ele.WriteStartElement("talentIcon"); ele.WriteAttributeString("id", "5"); ele.WriteString2(talentIcon); ele.WriteEndElement();
         ele.WriteStartElement("normalSkill"); ele.WriteAttributeString("id", "6"); ele.WriteInt(normalSkill); ele.WriteEndElement();
         ele.WriteStartElement("holeSetting"); ele.WriteAttributeString("id", "7"); cfg.Extensions.xml_marshal_list_cfg_equip_HoleSetting(holeSetting,ele); ele.WriteEndElement();
         
    }

    public override void UnmarshalXml(XmlElement ele)
    {
        foreach (XmlElement e in ele.GetChildren())
        {
            if (int.TryParse(ele.GetAttribute("id"), out var _id_))
            {
                switch (_id_)
                {
                case 1:  weaponType = ele.ReadEnum<cfg.equip.EWeaponType>(); break; 
                 case 2:  weaponTypeIcon = ele.ReadString2(); break; 
                 case 3:  name = ele.ReadString2(); break; 
                 case 4:  featureIcon = ele.ReadString2(); break; 
                 case 5:  talentIcon = ele.ReadString2(); break; 
                 case 6:  normalSkill = ele.ReadInt(); break; 
                 case 7:  holeSetting = cfg.Extensions.xml_unmarshal_list_cfg_equip_HoleSetting(ele); break; 
                 
                default: break;
                }
            }
            else
            {
                switch (e.Name)
                {
                case "weapon_type":  weaponType = ele.ReadEnum<cfg.equip.EWeaponType>(); break; 
                 case "weapon_type_icon":  weaponTypeIcon = ele.ReadString2(); break; 
                 case "name":  name = ele.ReadString2(); break; 
                 case "feature_icon":  featureIcon = ele.ReadString2(); break; 
                 case "talent_icon":  talentIcon = ele.ReadString2(); break; 
                 case "normal_skill":  normalSkill = ele.ReadInt(); break; 
                 case "hole_setting":  holeSetting = cfg.Extensions.xml_unmarshal_list_cfg_equip_HoleSetting(ele); break; 
                 
                default: break;
                }
            }
        }
    }
}
}
}
